# -*- coding:utf-8 -*-
# @Time      :2022/10/25 13:51
# @Author    :To me
# @Email     :2086351502@qq.com
# @File      :ModelsMinxin.py
# @File      :PyCharm
from django.db import models


class DateTimeModelsMixin(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        abstract = True


class IsDeleteModelsMixin(models.Model):
    is_delete = models.BooleanField(default=False, verbose_name='逻辑删除')

    class Meta:
        abstract = True

    def delete(self, using=None, keep_parents=False):
        self.is_delete = True
        self.save()


class Model(DateTimeModelsMixin, IsDeleteModelsMixin):
    class Meta:
        abstract = True
